package com.huadi.controller;

import com.huadi.domain.Exam;
import com.huadi.service.ExamService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

@Controller
@RequestMapping("/exam")
public class ExamController {
    @Resource
    private ExamService service;


    @RequestMapping("/addExam.do")
    public ModelAndView addExam(Exam exam){
        ModelAndView mv = new ModelAndView();
        String tips = "注册失败";

        int nums = service.addExam(exam);
        if( nums > 0 ){
            //注册成功
            tips = "考试信息表【" + exam.getExam_id() + "】注册成功";
        }
        //添加数据
        mv.addObject("tips",tips);
        //指定结果页面
        mv.setViewName("result");
        return mv;

    }

}
